package cn.gson.boot.model.service;

import cn.gson.boot.model.dao.CaringDao;
import cn.gson.boot.model.mapper.CaringMapper;
import cn.gson.boot.model.pojos.Caring;
import cn.gson.boot.model.pojos.CaringType;
import cn.gson.boot.model.pojos.Contacts;
import cn.gson.boot.model.pojos.Kehu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CaringService {
    @Autowired
    CaringMapper caringMapper;
    @Autowired
    CaringDao caringDao;

    //客户关怀分页
    public List<Caring> selectCaring(String search,String type,String empName){
        return caringMapper.selectCaring(search,type,empName);
    }

    //通过id查询需要修改的客户关怀
    public List<Caring> selectId(Integer caringId){
        return caringMapper.selectId(caringId);
    }

    //关怀类型列表
    public List<CaringType> selectType(){
        return caringMapper.selectType();
    }

    //新增客户关怀
    public void addCaring(Caring caring){
        caring.setCaringSc(0);
        caringDao.save(caring);
    }

    //删除客户关怀
    public void delCaring(Integer caringId) {
        Caring caring = caringDao.findById(caringId).get();
        caring.setCaringSc(1);
        caringDao.save(caring);
    }

    //客户模糊查询列表
    public List<Kehu> selectKh(String khsearch,String empName){
        return caringMapper.selectKehu(khsearch,empName);
    }

    //客户联系人查询
    public List<Contacts> selectLxr(String khName){
        return caringMapper.selectLxr(khName);
    }

}
